import cv2
import numpy as np

cat = cv2.imread("../images/cat.jpg")
print(cat)
cat_new = cat.copy()
b = cat_new[:, :, 0]
g = cat_new[:, :, 1]
r = cat_new[:, :, 2]
print("b------")
print(b)
print("g------")
print(g)
print("r------")
print(r)

cat_rgb = cv2.merge([r, g, b])  # 合并通道
cat_bgr = cv2.merge([b, g, r])  # 合并通道
print(cat_rgb[98:100, 98:100])
print(cat_bgr[98:100, 98:100])

cv2.imshow("cat", cat)
cv2.imshow("cat_rgb", cat_rgb)
cv2.imshow("cat_bgr", cat_bgr)
res = np.hstack((b, g, r))
cv2.imshow("res", res)
cv2.waitKey()